//
//  M1CornerImageView.m
//  NewMarryU
//
//  Created by apple on 2018/7/11.
//  Copyright © 2018年 Cedar. All rights reserved.
//

#import "M1CornerImageView.h"

@implementation M1CornerImageView

-(void)setCornerRadius:(float)cornerRadius{
    _cornerRadius = cornerRadius;
    
}

-(void)layoutSubviews{
    if (_cornerRadius == 0) {
        return;
    }
    
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:UIRectCornerAllCorners cornerRadii:CGSizeMake(_cornerRadius, _cornerRadius)];
    
    CAShapeLayer *maskLayer = [[CAShapeLayer alloc]init];
    //设置大小
    maskLayer.frame = self.bounds;
    //设置图形样子
    maskLayer.path  = maskPath.CGPath;
    
    self.layer.mask  = maskLayer;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
